﻿<!-- #include file="cjf.asp" -->
<%if request("act")="out" then%><div style="display: none">
    <%else%>
    <%end if%><!--#include file="conn.asp"--><!--#include file="inc/CHAR.INC"-->
    <html>
    <head>
        <title>漫画采集</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link href="images/style.css" type="text/css" rel="stylesheet">
        <script language="JavaScript" src="inc/js.js" type="text/javascript"></script>
    </head>
    <body>
        <center>
            <table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC"
                style="margin-top: 5px">
                <tr bgcolor="3972B4">
                    <td width="100%" colspan="3" bgcolor="e7e7e7">
                        <%
set rs=server.CreateObject("ADODB.RecordSet")
if request("itemid")<>"" then
startid=request("startid")
	sql="select * from cjitem where id="&request("itemid")
rs.open sql,conn,1,3
itemlist=rs("item")
endid=rs("endid")

if int(startid) > int(endid) then
   Response.write "本项目采集完成，共入库到"&endid+1&"个漫画,<a href=cjzjitem_manage.asp>返回</a>"
   Response.End
else
rs("startid")=rs("startid")+1

end if
rs.update
rs.close
itemlist1=Split(itemlist,"|")
s=ubound(itemlist1)
itemlist2=itemlist1(startid)
itemlist3=Split(itemlist2,",")
sql="select * from cjlog where id="&itemlist3(1)
else
cjid=request("cjid")
sql="select * from cjlog where id="&cjid
end if


rs.open sql,conn,1,3
cjid1=rs("id")
mcmc=rs("mcmc")
cjid2=rs("cjid")
comicid=rs("mhid")
rs.close

sql="select * from cjxm where id="&cjid2
rs.open sql,conn,1,3
xmmc=rs("xmmc")
xmfd=rs("xmfd")
picxz=rs("picxz")
xmsx=rs("xmsx")
fnbody=rs("fnbody")
fnfg=rs("fnfg")
fnid=rs("fnid")
fnmc=rs("fnmc")
mhurl=rs("mhurl")
mhbody=rs("mhbody")
mhmc=rs("mhmc")
mhtp=rs("mhtp")
mhtpurl=rs("mhtpurl")
mhzz=rs("mhzz")
mhjs=rs("mhjs")
mhzt=rs("mhzt")
mhfg=rs("mhfg")
mhzj=rs("mhzj")
wj=rs("wj")
lz=rs("lz")
mhzjid=rs("mhzjid")
rs.close
if request("cjurl")="" then
cjurl=mhurl
cjurl=Replace(cjurl,"[ID]",""&comicid&"") 
else
cjurl=request("cjurl")
end if
url=cjurl
if url="" then
   Response.write "&nbsp;请输入漫画页地址&nbsp;&nbsp;<A HREF=# onclick=""Javascript:history.back(-1)""><FONT  COLOR=#FF0000>请点这里返回</FONT></A>"
   Response.End
end if
   MusicMake
Sub MusicMake

MakeIMG
End Sub

Sub MakeIMG
Dim k:k=0




url=bqtf1(url)
mhbody=bqtf1(mhbody)
mhmc=bqtf1(mhmc)
mhtp=bqtf1(mhtp)
mhtpurl=bqtf1(mhtpurl)
mhzz=bqtf1(mhzz)
mhjs=bqtf1(mhjs)
mhzt=bqtf1(mhzt)
mhfg=bqtf1(mhfg)
mhzj=bqtf1(mhzj)
mhzjid=bqtf1(mhzjid)
mhzj=Replace(mhzj,"[ID]",""&comicid&"") 
mhzjid=Replace(mhzjid,"[ID]",""&comicid&"") 

mhbody1=Split(mhbody,"$")
mhmc1=Split(mhmc,"$")
mhzz1=Split(mhzz,"$")
mhtp1=Split(mhtp,"$")
mhjs1=Split(mhjs,"$")
mhzt1=Split(mhzt,"$")
mhzj1=Split(mhzj,"$")
mhzjid1=Split(mhzjid,"$")


zlp=GetHttp(url) 

'采集相关信息开始
body=GetStr(zlp,mhbody1(0),mhbody1(1))
mhzz2=GetStr(body,mhzz1(0),mhzz1(1))
mhtp2=GetStr(body,mhtp1(0),mhtp1(1))
mhjs2=GetStr(body,mhjs1(0),mhjs1(1))
mhzt2=GetStr(body,mhzt1(0),mhzt1(1))
mhmc2=GetStr(body,mhmc1(0),mhmc1(1))
mhmc2=Split(mhmc2,"[")
mhmc3=mhmc2(0)

body2=Split(body,""&mhfg&"")
zjs=ubound(body2) 
'开始写入数据
if trim(mhzz2)="" then
mhzz2="作者未知"
end if

if mhzz2<>"" then
zzzm=left(getpychar(trim(mhzz2)),1)
if zzzm="" then
zzzm=0
end if
Sql="Select * From zz where zzmc='"&trim(mhzz2)&"'"
Rs.Open Sql,Conn,1,3
if rs.eof then
Rs.AddNew
rs("zzmc")=trim(mhzz2)
rs("zm")=zzzm
if mhzz2<>"" then

Response.write "<font color=red>漫画作者:"&mhzz2&"("&getpychar(trim(mhzz2))&")&nbsp;"
end if
rs.update
rs.close
Sql="Select * From zz where zzmc='"&trim(mhzz2)&"'"
Rs.Open Sql,Conn,1,3
zzid=rs("id")
rs.close
Response.write "&nbsp;"&zzid&"&nbsp;入库成功</font>"
else
zzid=rs("id")
Response.write "<font color=red>漫画作者:"&mhzz2&"("&getpychar(trim(mhzz2))&")&nbsp;&nbsp;"&zzid&"&nbsp;存在</font>"
rs.close
end if
else
zzid=0
end if
mhzm=left(getpychar(trim(mhmc3)),1)
if mhzm="" then
mhzm=0
end if
cjitemid=cjid1&","&comicid
if mhzt2=wj then
zt=1
else
zt=0
end if
Sql="Select * From comics where cjitemid='"&trim(cjitemid)&"'"
Rs.Open Sql,Conn,1,3
if rs.eof then
Rs.AddNew
rs("classid")=0
rs("hits_d_d")=now()
rs("hits_m_d")=now()
rs("hits_w_d")=DatePart("ww", now())
rs("mhmc")=trim(mhmc3)
rs("zzid")=trim(zzid)
rs("zm")=trim(mhzm)
rs("mhjs")=mhjs2
rs("zt")=zt
rs("adddate")=now()
rs("cjid")=cjid2

rs("cjitemid")=trim(cjitemid)
Response.write "<br><font color=red>漫画:"&mhmc3&"("&mhzm&")&nbsp;资料入库成功</font>"
rs.update
rs.close
Sql="Select * From comics where cjitemid='"&trim(cjitemid)&"'"
Rs.Open Sql,Conn,1,3
comic_id=rs("id")
savepath="../cpic/"&comic_id&".jpg"
if xmfd=true then
getPICurl=""&web_url&"/inc/picpj.asp?url="&mhtpurl&""&mhtp2&""
else
getPICurl=""&mhtpurl&""&mhtp2&""
end if

Set fso = Server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(server.mappath(savepath))=false then
Response.write "<Br><font color=red>下载图片："&mhtpurl&""&mhtp2&" 保存为："&savepath&"</font>"
call saveimg(getPICurl,savepath)
else
Response.write "<Br><font color=red>下载图片："&mhtpurl&""&mhtp2&" 保存为："&savepath&" </font>&nbsp;<font color=blue>图片存在，已跳过</font>"
end if
rs("mhfm")=comic_id&".jpg"
rs.update
rs.close
else
comic_id=rs("id")
Response.write "<br><font color=red>漫画:"&mhmc3&"("&mhzm&")&nbsp;资料已存在</font>"

rs.update
rs.close
end if




'===================================================
'RString=DeHttpdata(zlp,"'[^<>'']*','[^<>'']*','[^<>""]*'")
Response.write "<table border=0 width=100% align=center>"
Response.write  "<tr><td width=100% colspan=""5"">"
Response.write "<Br>漫画名称："&mhmc3&""
Response.write "<Br>漫画作者："&mhzz2&""
Response.write "<Br>漫画封面："&mhtp2&""
Response.write "<Br>漫画介绍："&mhjs2&""
Response.write "<Br>漫画状态："&mhzt2&""
Response.write "<Br>漫画封面："&mhtpurl&""&mhtp2&""
Response.Write "<br><br>&nbsp;&nbsp;本漫画共有： "&zjs&"个章节</b>"

Response.write "</td></tr>"
for i=0 to zjs-1
fnidx=fnidx&i
fnidx=GetStr(body2(i),mhzj1(0),mhzj1(1))
zjidx=GetStr(body2(i),mhzjid1(0),mhzjid1(1))
comicitemid=cjid1&","&cjid2&","&comicid&","&comic_id&","&zjidx
fnidx=Replace(fnidx,""&trim(mhmc3)&"_","") 
fnidx=Replace(fnidx,""&trim(mhmc3)&"","") 

if (i mod 3)=0 and i>=3 then
Response.write "<tr>"
end if
Response.Write "<td>&nbsp;&nbsp;"&fnidx&"&nbsp;&nbsp;"&fnmcx&""
Sql="Select * From zjlog where comicitemid='"&trim(comicitemid)&"'"
Rs.Open Sql,Conn,1,3
if rs.eof then
Rs.AddNew
rs("zjmc")=fnidx
rs("cjwebid")=cjid2
rs("cjcid")=comicid
rs("cjzjid")=trim(zjidx)
rs("comicid")=comic_id
rs("cjcomicid")=cjid1
rs("comicitemid")=comicitemid
rs.update
rs.close
Response.Write "<font color=red>成功</font><td>"
else
Response.Write "<font color=blue>存在</font><td>"
rs.close
end if
response.flush
if (i mod 3)=0 and i>=3 then
Response.write "</tr>"
end if
next
response.flush

Response.write "</table>"
End Sub
if request("itemid")<>"" then
Response.write "&nbsp;<font color=red>继续下一个漫画</font>"
Response.write "<meta http-equiv=""refresh"" content=""0;url='cj_comic.asp?itemid="&request("itemid")&"&startid="&request("startid")+1&""">"
else
Response.write "<br><a href=cjzj_manage.asp?cjcomicid="&cjid1&">进入章节图片下载采集</a>"

end if
                        %>
                    </td>
                </tr>
            </table>
        </center>
    </body>
    </html>
